﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/admin.master" AutoEventWireup="true" Inherits="Admin_Manage_Users" Codebehind="manage-users.aspx.cs" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="<%= Utilities.SiteSettings.BaseUrl %>scripts/jquery.tmpl.js" type="text/javascript"></script>
	<link rel="stylesheet" href="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/grid.css" />
    <script src="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/grid.js"></script>
	<script src="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/pager.js"></script>
    <link rel="stylesheet" href="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/loader.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  

    <script type="text/javascript">
        function LoadPager() {
            
            var serviceUrl = "../Services/SocialShare_Service.svc/SocialShare_Members/$count";
            var filterVal = $("#txtEmail").val();
            if (filterVal != "") {
                serviceUrl = "../Services/SocialShare_Service.svc/SocialShare_Members/$count/?$filter=substringof('" + filterVal + "',Email)";
            }
            $.ajax({
                type: "GET",
                url: serviceUrl,
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    totalCount = data;
                    SetPager(0);
                },
                error: function (msg) {
                    alert(msg);
                }
            });          
        }

        function Filter() {
            currentPageIndex = 0;
            LoadPager();
            LoadData(0);
        }
        function LoadData(currentIndex) {

            var serviceUrl = "../Services/SocialShare_Service.svc/SocialShare_Members?"+ "&$orderby=" + sortItem + " " + sortIDirection + "&$skip=" + (currentIndex * pageSize) + "&$top=" + pageSize;
            var filterVal = $("#txtEmail").val();
            if (filterVal != "") {
                serviceUrl = "../Services/SocialShare_Service.svc/SocialShare_Members?$filter=substringof('" + filterVal + "',Email)" + "&$orderby=" + sortItem + " " + sortIDirection + "&$skip=" + (currentIndex * pageSize) + "&$top=" + pageSize;
            }
            $.ajax({
                type: "GET",
                url: serviceUrl,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () { $("#wait").show(); },
                complete: function () { $("#wait").hide(); },
                success: function (data) {
                    localDevelopers = data.d;
                    $("#users").html("");
                    $.each(data.d, function (i, item) {
                        var col1 = $("<td class='ui-state-custom-default'>").append(item.Member_Id).append("</td>");
                        var col2 = $("<td class='ui-state-custom-default'>").append(item.ScreenName).append("</td>");
                        var createDt = null;

                        if (item.CreateDate != 'undefined' && item.CreateDate != null) {
                            var s = item.CreateDate.toString(); //	/Date(1296074816700)/
                            s = s.slice(6, 19);
                            var n = parseInt(s);
                            createDt = new Date(n);
                        }
                        var col3 = "";

                        if (createDt != null) {
                            
                            col3 = $("<td class='ui-state-custom-default'>").append(dateFormat(createDt.toString(), "fullDate")).append("</td>");
                            
                        }
                        else {
                            col3 = $("<td class='ui-state-custom-default'>").append(" ").append("</td>");
                        }
                        var col4 = $("<td class='ui-state-custom-default'>").append(item.Email).append("</td>");
                        var col5 = $("<td class='ui-state-custom-default'>").append("<a href='edit-user.aspx?Id=" + item.Member_Id + "'>edit</a>").append("</td>");
                        $("<tr class='ui-state-custom-default'>").append(col1).append(col2).append(col3).append(col4).append(col5).append("</tr>").appendTo("#users"); ;

                    });
                    $('#dataTable tbody tr:even').addClass('grid-normal');
                    $('#dataTable tbody tr:odd').addClass('grid-alternate');
                },
                error: function (msg) {
                    alert(msg);
                }
            });
        }
        
    </script> 
  

<section class="grid_12 clearfix omega">
<section class="grid_12 clearfix omega">
<section id="wait" class="progress grid_5">
  <section class="progress-container">
        <section class="progress-header">Loading, please wait...</section>
        <section class="progress-body">
            <img src="../Scripts/Grid/pre-loader.gif" />
        </section>
    </section>
  
  </section>
  <section class="grid_7">
  &nbsp;
  </section>
</section>
<section class="grid_12 omega">
<fieldset>
<legend class="title-regular">Filter</legend>
    <input id="txtEmail" type="email"  placeholder="Email" /><input id="btnFilter" type="button" value="serach" class="button small red" onclick="javascript:Filter();return false;" />
    </fieldset>

<table id="dataTable" width="100%" class="ui-custom-grid">
<caption>Site Users</caption>
  <thead>
    <tr class="ui-state-custom-default">
      <th sort-data="Member_Id" class="grid-header-asc">Id</th>
      <th sort-data="ScreenName" class="grid-header-asc">ScreenName</th>
      <th sort-data="CreateDate" class="grid-header-asc">Create Date</th>
      <th sort-data="Email" class="grid-header-asc">Email</th>
       <th>&nbsp;</th>
    </tr>
  </thead>
  <tbody id="users">
  </tbody>
  <tfoot>
  <tr> <th align="center"" colspan="5">
  
   <section class="grid_10 clearfix grid-pager">
<a href="" class="button small blue pager-first" data-page="first">First</a>
    <a href="" class="button small green pager-prev" data-page="prev">Prev</a>	
	<span>
		Page <span class="current"></span>/<span class="total">0</span>,
		Total records <span class="totalRecords">0</span>
	</span>
	<a href=""  class="button small green pager-next" data-page="next">Next</a>
	<a href=""  class="button small blue pager-last" data-page="last">Last</a>
</section>
  </th>
  
  </tr>
 
  </tfoot>
</table>
</section>
</section>


</asp:Content>
